package com.ruoyi.web.controller.order;

import com.ruoyi.order.domain.OrderTicket;
import com.ruoyi.order.service.IOrderTicketService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.order.service.IOrderTicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 影票订单Controller
 *
 * @author HHAOYU
 * @date 2020-12-14
 */
@RestController
@RequestMapping("/order/orderTicket")
public class OrderTicketController extends BaseController
{
    @Autowired
    private IOrderTicketService orderTicketService;

    /**
     * 查询影票订单列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderTicket:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderTicket orderTicket)
    {
        startPage();
        List<OrderTicket> list = orderTicketService.selectOrderTicketList(orderTicket);
        return getDataTable(list);
    }

    /**
     * 导出影票订单列表
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderTicket:export')")
    @Log(title = "影票订单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OrderTicket orderTicket)
    {
        List<OrderTicket> list = orderTicketService.selectOrderTicketList(orderTicket);
        ExcelUtil<OrderTicket> util = new ExcelUtil<OrderTicket>(OrderTicket.class);
        return util.exportExcel(list, "orderTicket");
    }

    /**
     * 获取影票订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderTicket:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(orderTicketService.selectOrderTicketById(id));
    }

    /**
     * 新增影票订单
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderTicket:add')")
    @Log(title = "影票订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderTicket orderTicket)
    {
        return toAjax(orderTicketService.insertOrderTicket(orderTicket));
    }

    /**
     * 修改影票订单
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderTicket:edit')")
    @Log(title = "影票订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderTicket orderTicket)
    {
        return toAjax(orderTicketService.updateOrderTicket(orderTicket));
    }

    /**
     * 删除影票订单
     */
    @PreAuthorize("@ss.hasPermi('cinema:orderTicket:remove')")
    @Log(title = "影票订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderTicketService.deleteOrderTicketByIds(ids));
    }
}
